<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- 引入easyui的样式 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css">   
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/icon.css">
<!-- 引入Js -->
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>配送点价格表</title>
</head>
<script type="text/javascript">
//显示增加
function showAddPointPrice(){
	$('#addPointPrice').window('open'); 
}
//增加框取消清除
function clearForm() {
	$('#ff').form('clear');
}
//显示修改
function showUpdatePointPrice(){
	var data = $('#pointprice').datagrid('getSelections');
	for (var i = 0; i < data.length; i++) {
		$("#uid").textbox('setValue',data[i].id);
		$("#ustartName").textbox('setValue',data[i].startName);
		$("#upointName").textbox('setValue',data[i].pointName);
		$("#ufirstPrice").textbox('setValue',data[i].firstPrice);
		$("#unextPrice").textbox('setValue',data[i].nextPrice);
		$("#ufirstcPrice").textbox('setValue',data[i].firstcPrice);
		$("#unextcPrice").textbox('setValue',data[i].nextcPrice);
	}
	if(data.length==1){
	$('#updatePointPrice').window('open');
	}
	else{
		alert("请选择一条数据");
	}
}
function selectPointPrice(){
	var pointName=$('#pointName').val();
	var grid = $('#pointprice');
	var options = grid.datagrid('getPager').data("pagination").options;  
    var curr = options.pageNumber; //获取当前页数 
    var total = options.total;  
    var max = Math.ceil(total/options.pageSize);
	$.messager.alert('提示', '查询成功', 'info',
				function() {
					$("#pointprice").datagrid({
				    	url:"${pageContext.request.contextPath}/pointprice/pointprice_selectPointPriceByPointName.do",
				    	queryParams: {
				    		pointName:pointName,
				    	} 
				    })
					$('#pointprice').dialog('close');
					});
			}
//增加数据
function addPointPrice() {
	$("#ff").form('submit', {
		url:"${pageContext.request.contextPath}/pointprice/pointprice_addPointPrice.do",
		success : function(data) {
			$.messager.alert('提示','添加成功','info',function(){
	    	$("#pointprice").datagrid('reload');
	    	$("#addPointPrice").window("close");
	    	});  	  
	}
	});
}
//修改数据
function updatePointPrice(){
	var rows = $('#pointprice').datagrid('getSelected');
	var id=$("#uid").textbox('setValue',rows.id);
	if(rows){
		$("#uf").form('submit', {
			url:"${pageContext.request.contextPath}/pointprice/pointprice_updatePointPrice.do?id"+id,
			success : function(data) {
				$.messager.alert('提示','修改成功','info',function() {
					$("#pointprice").datagrid('reload');
			    	$("#updatePointPrice").window("close");
			    	});
		}
		});
	}
} 
//删除数据
function delPointPrice(){
			var rows = $('#pointprice').datagrid('getSelections');
			var ids = new Array();
			for (var i = 0; i < rows.length; i++) {
				ids[i] = rows[i].id;
			}
			if (rows) {
						$.post('${pageContext.request.contextPath}/pointprice/pointprice_delPointPrice.do', {
							'ids' : ids
						}, function(result) {
							$('#pointprice').datagrid('reload'); // reload the user data
						});
			}
		}

</script>
<body>
<table id="pointprice" title="配送点价格表" class="easyui-datagrid" pagination="true"
    		toolbar="#toolbar" fit="true"
    		url="${pageContext.request.contextPath}/pointprice/pointprice_selectPointPrice.do"
    		rownumbers="true" fitColumns="true">
    	<thead>
    		<tr>
    		<th field="ck" checkbox="true"></th>
    			<th field="id" width="50">Id</th>
    			<th field="startName" width="50">发货配送点名称</th>
    			<th field="pointName" width="50">收货配送点名称</th>
    			<th field="firstPrice" width="50">首重价格</th>
    			<th field="nextPrice" width="50">次重价格</th>
    			<th field="firstcPrice" width="50">首立方价格</th>
    			<th field="nextcPrice" width="50">次立方价格</th>
    		</tr>
    	</thead>
    </table>
    <div id="toolbar">
    	请输入配送点名称:<input type="text" id="pointName" name="pointName">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="selectPointPrice()">查询</a>
    	<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="showAddPointPrice()">增加</a>
    	<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="showUpdatePointPrice()">修改</a>
    	<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delPointPrice()">删除</a>
    </div>
    <!-- 增加数据显示框 -->
    <div class="easyui-window" closed="true" id="addPointPrice" title="信息增加"
		 data-options="modal:true">
		<form id="ff" method="post" style="text-align: center">
			<%-- <p>
			             发货配送点名称: <input id="startName" class="easyui-combobox" name="startName" editable:false
    			  data-options="valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/pointprice/pointprice_findPiontName.do'"/>
    			  </p>
    		<p>
			             发货配送点名称: <input id="pointName" class="easyui-combobox" name="pointName" editable:false
    			  data-options="valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/pointprice/pointprice_findPiontName.do'"/>
    			  </p> --%>
			<p>
				发货配送点名称:<input name="startName" id="startName" class="f1 easyui-textbox"	
					data-options="required:true,missingMessage:'请输入数据'" />
			</p> 
			<p>
				收货配送点名称:<input name="pointName" id="pointName" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				首重价格:<input name="firstPrice" id="firstPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				次重价格:<input name="nextPrice" id="nextPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				首立方价格:<input name="firstcPrice" id="firstcPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				次立方价格:<input name="nextcPrice" id="nextcPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<div style="padding: 5px; text-align: center;">
				<a href="#" class="easyui-linkbutton" icon="icon-ok"
					onclick="addPointPrice()">确认</a> 
					<a href="#" class="easyui-linkbutton"
					icon="icon-cancel" onclick="clearForm()">取消</a>
			</div>
		</form>
	</div>
	<!-- 修改数据显示框 -->
	<div id="updatePointPrice" class="easyui-window" closed="true" id="addPointPrice" title="信息修改"
		 data-options="modal:true">
		<form id="uf" method="post" type="hidden" style="text-align: center">
			
			<p>
				发货配送点名称:<input name="startName" id="ustartName" class="f1 easyui-textbox"	data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				收货配送点名称:<input name="pointName" id="upointName" class="f1 easyui-textbox" 
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				首重价格:<input name="firstPrice" id="ufirstPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				次重价格:<input name="nextPrice" id="unextPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				首立方价格:<input name="firstcPrice" id="ufirstcPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<p>
				次立方价格:<input name="nextcPrice" id="unextcPrice" class="f1 easyui-textbox"
					data-options="required:true,missingMessage:'请输入数据'" />
			</p>
			<div style="display: none;"><input name="id" id="uid" class="f1 easyui-textbox"/></div>
			<div style="padding: 5px; text-align: center;">
				<a href="#" class="easyui-linkbutton" icon="icon-ok"
					onclick="updatePointPrice()">确认</a> 
					<a href="#" class="easyui-linkbutton"
					icon="icon-cancel" onclick="javascript:$('#updatePointPrice').dialog('close')">取消</a>
			</div>
		</form>
	</div>
</body>
</html>